package com.yr.ryjk.param;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yr.ryjk.common.ErrorType;
import com.yr.ryjk.interceptor.authority.For;
import com.yr.ryjk.interceptor.authority.UserType;
import com.yr.ryjk.param.entity.Param;
import com.yr.ryjk.param.service.IParamService;
import com.yr.ryjk.util.JSONUtil;
/**
 * 系统参数
 * @author ZhangKai
 *
 */
@For(user=UserType.WEBSERVER_USER)
@Controller
@RequestMapping("/param")
public class ParamController {
	@Autowired
	private IParamService paramService;

	/**
	 * 分页获取数据
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
			@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
			@RequestParam("des")String des,
			@RequestParam("keyword")String keyword) {
		return JSONUtil.getJSON(ErrorType.SUCCESS,
			paramService.getListOfPage(pageNo, pageSize,des,keyword));
	}

	/**
	 * 根据keyword获取详细信息
	 * @param keyword
	 * @return
	 */
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getParamInfo(String keyword) {
		return JSONUtil.getJSON(ErrorType.SUCCESS,paramService.getParamByKeyword(keyword));
	}

	/**
	 * 修改信息
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "/modify", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> modifyParam(Param param) {
		paramService.modifyParamInfo(param);
		return JSONUtil.getJSON(ErrorType.SUCCESS);
	}
	
	/**
	 * app端获取关于我们
	 * @return
	 */
	@For(user=UserType.APP_USER)
	@RequestMapping(value = "/getAboutUs", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getAboutUs() {
		return JSONUtil.getJSON(ErrorType.SUCCESS,paramService.getAboutUs());
	}
	
}
